package com.guangzhi.weijianzhi.adapter;

import java.util.ArrayList;

import com.guangzhi.weijianzhi.R;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class DialogAdapter extends BaseAdapter{

	private Context context=null;
	private ArrayList<String> list=null;
	private LayoutInflater inflater=null;
	public DialogAdapter(Context contex,ArrayList<String> list){
		this.context = context;
		this.list = list;
		inflater = LayoutInflater.from(contex);
	}
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return list.size();
	}

	@Override
	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return list.get(arg0);
	}

	@Override
	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return arg0;
	}
	@Override
	public View getView(int arg0, View contentView, ViewGroup arg2) {
		// TODO Auto-generated method stub
		ViewHolder  holder =null;
		if(contentView == null){
			contentView = inflater.inflate(R.layout.jzcompinf_dialog_select_item, null, true);
			holder = new ViewHolder();
			holder.textView = (TextView) contentView.findViewById(R.id.jzcompinf_dialog_select_item_textView);
			contentView.setTag(holder);
		}else{
			holder = (ViewHolder) contentView.getTag();
		}
		holder.textView.setText(list.get(arg0));
		return contentView;
	}
	private class ViewHolder{
		private TextView textView;
	}
}
